module.exports = {
    open: false,
    description: '回复评论',
    handler(req, res, next) {
        let doc = req.body;
        let commentID = doc.commentID;
        let date = new Date();
        doc.createTime = date;
        req.mongo.collection("reply").insertOne(
            doc,
            (e, r) => {
                if (e) return res.err.mongoError(e);
                let replyID = r.insertedId;
                req.mongo.collection("comment").updateOne(//将新产生的reply的_id（即r.insertedId）插入到comment集合的replyID数组中
                    {"_id": commentID},
                    {$push: {"replyID": replyID}, $set: {"lastModifyDate": date}},
                    {upsert: true},
                    (error, result) => {
                        if (error) return res.err.mongoError(error);
                        let obj = new Object();
                        obj._id = replyID;
                        return res.reply(obj);
                    }
                )

            })

    }
};